<?php

namespace frontend\models\register;

use Yii;
use yii\base\Model;
use frontend\models\User;

/**
 * ContactForm is the model behind the contact form.
 */
class RegisterForm extends User
{
    public $user_name;
    public $user_email_phone;
    public $user_pwd;
    public $user_qrpwd;
    public $user_code;

    /**
     * @inheritdoc 验证规则
     */
    public function rules()
    {
		
        return [
			[['user_email_phone', 'user_name','user_pwd','user_qrpwd','user_code'], 'required','message'=>'当前项不能为空'],
   			[[ 'user_code'], 'integer'],
            [['user_email_phone'], 'string', 'max' => 40],
			[['user_email_phone'], 'match','pattern' => '/^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$|^([a-z0-9A-Z]+[-|\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\.)+[a-zA-Z]{2,}$/i','message'=>'请输入正确的手机或邮箱'],
            ['user_email_phone', 'unique', 'targetAttribute' => 'user_email', 'message'=>'邮箱已被占用'],
            ['user_email_phone', 'unique', 'targetAttribute' => 'user_phone',  'message'=>'手机号已被占用'],
            [['user_name'], 'match', 'pattern' => '/^([\x{4e00}-\x{9fa5}]|\w){2,18}$/u', 'message' => '昵称为2-18位,中英文、数字、下划线'],
            [['user_name'], 'unique','targetClass' => '\frontend\models\User','message'=>'昵称已存在'],
            [['user_pwd'], 'string', 'min'=>6, 'max' => 16,'tooLong'=>'密码不得多于16位', 'tooShort'=>'密码不得少于6位'],
			[['user_qrpwd'],'compare','compareAttribute'=>'user_pwd','message'=>'确认密码与密码不同'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'user_email_phone' => '',
            'user_name' => '',
            'user_pwd' => '',
            'user_qrpwd' => '',
			'user_code' => '',
        ];
    }

}